package com.briup.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 * 使用jdbc 完成数据删除
 * jdbc 默认提交事务
 */
public class DeleteData {
    public static void main(String[] args) {
        String name="mjj create";
        Connection connection = null;
        Statement statement = null;
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            connection = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:xe", "bttc2", "bttc2");
            System.out.println(connection.getAutoCommit());
            connection.setAutoCommit(false);
            statement = connection.createStatement();
            String sql = "delete  from TEAM";
            int i = statement.executeUpdate(sql);
            System.out.println(i);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (connection != null)
                    connection.close();
                if (statement!=null)
                    statement.close();
            } catch (Exception e) {

            }
        }
    }
}
